#ifndef GWDETECTOR_H
#define GWDETECTOR_H

#include <QGraphicsItem>
#include <QObject>
#include <QTimeLine>
#include <property/qttreepropertybrowser.h>
#include <property/qtvariantproperty.h>
#include "GraphicsType.h"
#include "fileeditfactory.h"
#include "GwGraphics_global.h"

class GWGRAPHICS_EXPORT GwDetector : public QObject,public QGraphicsItem
{
    Q_OBJECT
public:
    explicit GwDetector();
    explicit GwDetector(const GwDetector &other);
    ~GwDetector();
    int getCHID();
    // QGraphicsItem interface
public:
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    void setPropertyTree(QtTreePropertyBrowser *treepro);
    void refreshProperty(QtProperty *item);
    void refreshPropertyList();
    void createPropertyList();
    void setCHID(int ch);
    void setConfig();
    GraphicsState getState();
    GwDetector & operator=(const GwDetector &other);
    friend QDataStream & operator >> (QDataStream &in,GwDetector& data);
    friend QDataStream & operator << (QDataStream &out,const  GwDetector& data);

private:


    QImage image;
    QRectF m_rect;

    QColor chColour;
    int flash=0;
    int range=16;
    int radius=60;
    int chID=0;
    bool isTest=false;

    QTimeLine *movie=NULL;

    GraphicsState itemstate=GState_OK;

    QList<QtProperty*> m_propertys;

    QtVariantPropertyManager *m_pVarManager=NULL;
    QtVariantEditorFactory *m_pVarFactory=NULL;

    fileEditFactory *m_stringFactory=NULL;
    QtStringPropertyManager *m_stringManager=NULL;


public slots:
    void propertyChanged(QtProperty *property, const QVariant &val);
    void movieRun(int frame);
    void setState(GraphicsState state);


    // QGraphicsItem interface
protected:
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
};

#endif // GWDETECTOR_H
